<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Establishes a connection to a Messaging Server</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="samconnection.commit.html">SAMConnection::commit</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="samconnection.construct.html">SAMConnection::__construct</a></div>
 <div class="up"><a href="ref.sam.html">SAM 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="samconnection.connect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SAMConnection::connect</h1>
  <p class="verinfo">(PECL sam &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">SAMConnection::connect</span> &mdash; <span class="dc-title">
   Establishes a connection to a Messaging Server
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-samconnection.connect-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>SAMConnection::connect</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$protocol</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$properties</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Calling the &quot;connect&quot; method on a SAMConnection object connects the PHP
   script to a messaging server. No messages can be sent or received until a
   connection is made.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-samconnection.connect-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-samconnection.connect-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   This method returns <strong><code>FALSE</code></strong> if an error occurs.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-samconnection.connect-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4424">
    <p><strong>Example #1 
     Creating a connection to a Messaging Server using the IBM MQSeries
     protocol (WMQ)
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$conn</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">connect</span><span style="color: #007700">(</span><span style="color: #0000BB">SAM_WMQ</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">SAM_HOST&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Myhost.myco.com'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SAM_PORT&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1506</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SAM_BROKER&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'MyBroker'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-4425">
    <p><strong>Example #2 
     Creating a connection with application transaction control and default
     host and port values
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$conn</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">connect</span><span style="color: #007700">(</span><span style="color: #0000BB">SAM_WMQ</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">SAM_BROKER&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'MyBroker'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SAM_TRANSACTIONS&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SAM_MANUAL</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-4426">
    <p><strong>Example #3 
     Creating a connection to a Messaging Server using the IBM WebSphere
     Platform Messaging protocol (WPM)
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$conn</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">connect</span><span style="color: #007700">(</span><span style="color: #0000BB">SAM_WPM</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">SAM_ENDPOINTS&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'localhost:7278:BootstrapBasicMessaging'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">SAM_BUS&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'Bus1'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SAM_TARGETCHAIN&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'InboundBasicMessaging'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-samconnection.connect-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="samconnection.isconnected.html" class="xref">SAMConnection::isConnected</a></li>
    <li class="member"><a href="samconnection.disconnect.html" class="xref">SAMConnection::disconnect</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="samconnection.commit.html">SAMConnection::commit</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="samconnection.construct.html">SAMConnection::__construct</a></div>
 <div class="up"><a href="ref.sam.html">SAM 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
